<template>
<div>
  <van-field placeholder="账号:" label="请输入账号" v-model="username"></van-field>
  <van-field placeholder="密码:" label="请输入密码" v-model="password"></van-field>
  <van-button @click="get_login">登录</van-button>
</div>
</template>

<script>
export default {
name: "login",
  data(){
  return{
    username:'',
    password:''
  }
  },
  methods:{
    get_login(){
      this.myaxios('http://localhost:5000/login','post',{'username':this.username,'password':this.password})
      .then(res=>{
        console.log(res)
        if (res.data.code==200){
          localStorage.setItem('userid',res.data.userid)
          localStorage.setItem('token',res.data.token)
          localStorage.setItem('username',res.data.username)
          this.$router.push({path:'/unifode'})
        }else {
          this.$toast.fail(res.data.msg)
        }
      })
    }
  },
  mounted() {
  }
}
</script>

<style scoped>

</style>
